package base.service.Impl;

import base.data.UsersBaseData;
import base.model.UserBaseModel;
import base.service.ILoginBaseService;

public class LoginBaseServiceImpl implements ILoginBaseService {

    //todo 示例登录业务逻辑接口实现类，完成作业时自行扩展

    protected UsersBaseData usersData;

    //todo 重写构造方法，新建实例对象时，获取数据源
    LoginBaseServiceImpl(){
       //Fixme 自行先重写 UsersData 的构造方法，进行数据初始化
       // usersData = new UsersData();
    }

    @Override
    public boolean checkLogin(UserBaseModel loginUser) {
        //通过用户名查询用户信息
        try{
            UserBaseModel user = usersData.get(loginUser.getUsername());
            if(user!=null){
                return user.getPassword().equals(loginUser.getPassword());
            }else{
                return false;
            }
        }catch (Exception ex){
            return false;
        }
    }
}
